package com.gwt.server.generator;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import com.gwt.server.domain.Beer;
import com.gwt.server.domain.BeerStyle;

public class BeerGenerator {

	private static Random r1 = new Random();
	private static Random r2 = new Random();

	private static final String[] firstDescriptor = { "Snake", "Black", "Blue", "Pine", "Red", "Scottish", "Coffee", "Brown", "Vanilla", "Bitter" };

	private static final String[] secondDescriptor = { "Dog", "English", "Moon", "Tree", "Screaming", "Nut", "Nobel", "Spice", "Imperial" };

	private static final String[] styles = { "Ale", "Lager", "Indian pale ale", "Extra special bitter", "Porter", "Red", "Brown", "Stout", "Pale ale", "Wheat",
			"Dunkel", "Tripel", "Labmic", "Pilsener", "Bock", "Sour", "Blond" };

	public static Beer makeBeer() {

		Random r3 = new Random(r1.nextLong() + r2.nextLong());

		String name = firstDescriptor[r1.nextInt(firstDescriptor.length)] + " " + secondDescriptor[r2.nextInt(secondDescriptor.length)];
		Beer newBeer = new Beer();

		BeerStyle newBeerStyle = new BeerStyle();
		newBeerStyle.setName(styles[r3.nextInt(styles.length)]);

		newBeer.setName(name);
		newBeer.setStyle(newBeerStyle);

		return newBeer;
	}

	public static List<Beer> getMoreBeer(int size) {
		List<Beer> beerList = new ArrayList<Beer>(size);
		for (int i = 0; i < size; i++) {
			beerList.add(makeBeer());
		}

		return beerList;
	}
}
